package app

import (
	"chatgpt/helper/code"
	"chatgpt/logq"
	"chatgpt/plugin/rpcx"
	"chatgpt/services/datasrv/sqlhelper"
	"context"
)

func (self *AppApi) BenefitSelect(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitSelect", req, res)
	if err != nil {
		logq.Error("DataSrv.Benefit.Select err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitSave(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitSave", req, res)
	if err != nil {
		logq.Error("DataSrv.Benefit.Save err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitTotal(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitTotal", req, res)
	if err != nil {
		logq.Error("DataSrv.Benefit.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitFirst(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitFirst", req, res)
	if err != nil {
		logq.Error("DataSrv.Benefit.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitDelete(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitDelete", req, res)
	if err != nil {
		logq.Error("DataSrv.Benefit.Delete err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

// benefit user

func (self *AppApi) BenefitUserSelect(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitUserSelect", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitUser.Select err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitUserSave(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitUserSave", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitUser.Save err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitUserTotal(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitUserTotal", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitUser.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitUserFirst(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitUserFirst", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitUser.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitUserDelete(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitUserDelete", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitUser.Delete err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

// BenefitScope

func (self *AppApi) BenefitScopeSelect(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitScopeSelect", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitScope.Select err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitScopeSave(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitScopeSave", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitScope.Save err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitScopeTotal(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitScopeTotal", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitScope.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitScopeFirst(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitScopeFirst", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitScope.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *AppApi) BenefitScopeDelete(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("AppApi")
	err := client.Call(ctx, "BenefitScopeDelete", req, res)
	if err != nil {
		logq.Error("DataSrv.BenefitScope.Delete err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}
